function isValidEmailAddress(emailAddress) 
{
	var pattern = new RegExp(/^[+a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/i);
	return pattern.test(emailAddress);
}

$(document).ready(function(){
	$("#btn_search").click(function(){
		
		var search = $('#s').val();
		if(search=='Nhập từ khóa..')
		{
			alert("Nhập từ khóa tìm kiếm.");
			return false;
		}
		else
			return true;
		
	});	
	
	$('#btn-send-sub-email').click(function(){
		
		var hidden_myurl_request = $("#hidden_myurl_request").val();
		var sub_email = $('#sub-email').val();
		
		if(sub_email=='Your Email')
		{
			alert('Please enter your email.');
			return false;
		}
		else if(!isValidEmailAddress(sub_email))
		{
				alert("Email invalid, Please try again.");
				return false;			
		}				
		else
		{
		
			$("#dkntt_show_message").html("Loading...");
			var user_string = sub_email;
			
			var myurl = hidden_myurl_request + '?action=dkntt&mystring='+ user_string;
			if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  	xmlhttp=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			xmlhttp.onreadystatechange=function()
			  {
			  	if (xmlhttp.readyState==4 && xmlhttp.status==200)
			  	{			  		
			    	document.getElementById("dkntt_show_message").innerHTML = xmlhttp.responseText;
			    	var myresult = document.getElementById("dkntt_show_message").innerHTML;
			    	alert(myresult);
			    	
			    }
			  }			 
			xmlhttp.open("GET",myurl,true);
			xmlhttp.send();
			return false;
			
		}	
	});
	
});